<template>
	<view>
		<view class="item" v-for="(res, index) in cardList" :key="res.id">
			<view class="top">
				<view>{{ res.cardInMachine.inMachinePlace }}</view>

				<view class="phone">{{ res.card.student.name }}</view>

				<view class="tag">
					<text v-for="(item, index) in res.tag" :key="index" :class="{ red: item.tagText == '默认' }">{{ item.tagText }}</text>
				</view>
			</view>
			<view class="bottom">
				<view class="name">卡号：{{ res.card.cardNum }}</view>
				<view>{{ res.inTime }}</view>
				<view style="left: 10;">金额：{{ res.inMoney }}</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	onLoad(id) {
		this.cardDataVo.data.id = id.id;
	},
	data() {
		return {
			cardList: [],
			cardDataVo: {
				data: {
					id: null
				},
				pageInfo: {
					pageNum: '1',
					pageSize: '7'
				}
			}
		};
	},
	// 触底加载更多
	onReachBottom() {
		this.cardDataVo.pageInfo.pageNum=parseInt(this.cardDataVo.pageInfo.pageNum)+1;
		this.getData();
	},
	methods: {
		getData() {
			this.$axios({
				method: 'post',
				url: '/api/cardIn/getByCardId',
				data: this.cardDataVo
			}).then(r => {
				if (r.data.code == 200) {
					if(r.data.data.list.length==0){
						uni.showToast({
						    title: '没有更多了',
						    icon: 'error'  
						});
						this.cardDataVo.pageInfo.pageNum=parseInt(this.cardDataVo.pageInfo.pageNum)-1;
					}
					this.cardList=this.cardList.concat( r.data.data.list);
				}
			});
		}
	},
	created() {
		this.getData();
	}
};
</script>

<style lang="scss" scoped>
.item {
	padding: 40rpx 20rpx;
	.top {
		display: flex;
		font-weight: bold;
		font-size: 34rpx;
		.phone {
			margin-left: 60rpx;
		}
		.tag {
			display: flex;
			font-weight: normal;
			align-items: center;
			text {
				display: block;
				width: 60rpx;
				height: 34rpx;
				line-height: 34rpx;
				color: #ffffff;
				font-size: 20rpx;
				border-radius: 6rpx;
				text-align: center;
				margin-left: 30rpx;
				background-color: rgb(49, 145, 253);
			}
			.red {
				background-color: red;
			}
		}
	}
	.bottom {
		display: flex;
		margin-top: 20rpx;
		font-size: 28rpx;
		justify-content: space-between;
		color: #999999;
	}
}
.addSite {
	display: flex;
	justify-content: space-around;
	width: 600rpx;
	line-height: 100rpx;
	position: absolute;
	bottom: 30rpx;
	left: 80rpx;
	background-color: red;
	border-radius: 60rpx;
	font-size: 30rpx;
	.add {
		display: flex;
		align-items: center;
		color: #ffffff;
		.icon {
			margin-right: 10rpx;
		}
	}
}
</style>
